package com.vcc.service.client.vo.comptroller;

import com.vcc.core.util.DateUtil;
import com.vcc.core.util.StringUtil;
import com.vcc.data.entity.Comptroller;
import com.vcc.data.entity.IpInfo;
import com.vcc.service.client.vo.baseVo.BaseVo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

@EqualsAndHashCode(callSuper = true)
@Data
@Setter
@Getter
public class ComptrollerVo extends BaseVo implements Serializable {

    private Long userId;
    private String account;
    private Integer useFlag;
    private Integer status;
    private String requestIp;
    private Long operationUserId;
    private String operationUserAccount;
    private String requestDate;
    private String country;
    private String region;
    private String city;
    private String area;

    public ComptrollerVo() {
    }


    public ComptrollerVo(Comptroller comptroller, String account, String operationUserAccount, IpInfo ipInfo) {
        super.setId(comptroller.getId());
        this.userId = comptroller.getUserId();
        this.account = StringUtil.hideMobile(account);
        this.useFlag = comptroller.getUseFlag();
        this.requestIp = comptroller.getRequestIp();
        this.operationUserId = comptroller.getOperationUserId();
        this.operationUserAccount = StringUtil.hideEmail(operationUserAccount);
        this.requestDate = DateUtil.format(comptroller.getRequestDate());
        this.country = ipInfo == null ? "" : ipInfo.getCountry();
        this.region = ipInfo == null ? "" : ipInfo.getRegion();
        this.city = ipInfo == null ? "" : ipInfo.getCity();
        this.area = ipInfo == null ? "" : ipInfo.getArea();
    }
}
